package com.ihd.ihardware.common.widget;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.ihd.ihardware.R;


public class ShareDialog extends Dialog {
    private View.OnClickListener mWechatBtnClickListener;
    private View.OnClickListener mMomentsClickListener;
    private Activity mActivity;

    public ShareDialog(Activity activity, View.OnClickListener wechatBtnClickListener, View.OnClickListener momentsClickListener) {
        super(activity, R.style.dialog_bg);
        mActivity = activity;
        mWechatBtnClickListener = wechatBtnClickListener;
        mMomentsClickListener = momentsClickListener;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View root = LayoutInflater.from(mActivity).inflate(R.layout.dialog_share,null);
        setContentView(root);
        findViewById(R.id.wechat).setOnClickListener(mWechatBtnClickListener);
        findViewById(R.id.moments).setOnClickListener(mMomentsClickListener);
        setCanceledOnTouchOutside(true);
        setCancelable(true);

        Window dialogWindow = getWindow();
        dialogWindow.setGravity(Gravity.BOTTOM);
        dialogWindow.setWindowAnimations(cn.wowjoy.commonlibrary.R.style.popupAnimation);
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.width = mActivity.getResources().getDisplayMetrics().widthPixels;
        root.measure(0, 0);
        lp.height = root.getMeasuredHeight();
        dialogWindow.setAttributes(lp);
    }

}
